package com.notetool.util.tokenparser.syntax;

import com.notetool.util.tokenparser.SingleCharToken;
import com.notetool.util.tokenparser.Token;

public class SingleCharModel extends Model
{
    
    ////////////////////
    // Members
    private char character;
    private boolean grouped; // If true, regroup neighbors if same SingleCharModel instance
    private boolean unique; // If true, eliminate neighbors if same Separator instance
    
    ////////////////////
    // Constructors
    public SingleCharModel (char charac)
    {
        character = charac;
        
        grouped = false;
        unique = false;
    }

    ////////////////////
    // Accessors
    public char getCharacter ()
    {
        return character;
    }
    
    public boolean isGrouped ()
    {
        return grouped;
    }
    
    public boolean isUnique ()
    {
        return unique;
    }
    
    ////////////////////
    // Model implementation
    
    ////////////////////
    // Public methods
    public SingleCharModel grouped ()
    {
        unique = false;
        grouped = true;
        
        return this;
    }
    
    public SingleCharModel unique ()
    {
        grouped = false;
        unique = true;
        
        return this;
    }
    
    public boolean matches (char token)
    {
        return (character == token);
    }
    
    public SingleCharToken instantiate ()
    {
        return new SingleCharToken (this);
    }
    
    public SingleCharModel addClass (String... clsses)
    {
        for (String curClass : clsses)
            super.addClass (curClass);
        
        return this;
    }
    
}
